/**
 * @date 2005-12-22 8:54:26
 *
 */
package org.nanhill.xsheet.xdata.model;

import java.util.ArrayList;
import java.util.List;

import org.nanhill.commons.lang.ArrayKit;

/**
 * @author alin
 * 
 */
public class XDataDefaultModel implements XDataModel {
	private List<Object[]> indexs;

	private List<Object[]> sets;

	public XDataDefaultModel() {
		this.indexs = new ArrayList<Object[]>();
		this.sets = new ArrayList<Object[]>();
	}

	public void addIndex(Object... index) {
		this.indexs.add(index);
	}

	public void addSet(Object... set) {
		this.sets.add(set);
	}

	public void expandSet(int index, Object... row) {
		Object[] srcSet = this.sets.remove(index);
		Object[] destSet = new Object[srcSet.length + row.length];
		ArrayKit.copyAll(destSet, 0, srcSet, row);
		this.sets.add(index, destSet);
	}

	public void expandLastSet(Object... row) {
		this.expandSet(this.sets.size() - 1);
	}

	public List<Object[]> getIndexs() {
		return indexs;
	}

	public List<Object[]> getSets() {
		return sets;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.nanhill.protocol.xdata.model.XDataModel#clearSet()
	 */
	public void clearSet() {
		this.sets.clear();
	}

}
